/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author VietTien
 */
@Entity
@Table(name = "Registration")
@NamedQueries({
    @NamedQuery(name = "Registration.findAll", query = "SELECT r FROM Registration r"),
    @NamedQuery(name = "Registration.findByRegID", query = "SELECT r FROM Registration r WHERE r.regID = :regID"),
    @NamedQuery(name = "Registration.findByStatusReg", query = "SELECT r FROM Registration r WHERE r.statusReg = :statusReg"),
    @NamedQuery(name = "Registration.findByRegTime", query = "SELECT r FROM Registration r WHERE r.regTime = :regTime"),
    @NamedQuery(name = "Registration.findByCancelTime", query = "SELECT r FROM Registration r WHERE r.cancelTime = :cancelTime"),
    @NamedQuery(name = "Registration.findByIsDelete", query = "SELECT r FROM Registration r WHERE r.isDelete = :isDelete")})
public class Registration implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "RegID")
    private Integer regID;
    @Basic(optional = false)
    @Column(name = "StatusReg")
    private String statusReg;
    @Basic(optional = false)
    @Column(name = "RegTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date regTime;
    @Column(name = "CancelTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date cancelTime;
    @Basic(optional = false)
    @Column(name = "isDelete")
    private boolean isDelete;
    @JoinColumn(name = "UserID", referencedColumnName = "UserID")
    @ManyToOne(optional = false)
    private UserInfo userInfo;
    @JoinColumn(name = "EventID", referencedColumnName = "EventID")
    @ManyToOne(optional = false)
    private EventInfo eventInfo;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "registration")
    private Collection<Winner> winnerCollection;

    public Registration() {
    }

    public Registration(Integer regID) {
        this.regID = regID;
    }

    public Registration(Integer regID, String statusReg, Date regTime, boolean isDelete) {
        this.regID = regID;
        this.statusReg = statusReg;
        this.regTime = regTime;
        this.isDelete = isDelete;
    }

    public Integer getRegID() {
        return regID;
    }

    public void setRegID(Integer regID) {
        this.regID = regID;
    }

    public String getStatusReg() {
        return statusReg;
    }

    public void setStatusReg(String statusReg) {
        this.statusReg = statusReg;
    }

    public Date getRegTime() {
        return regTime;
    }

    public void setRegTime(Date regTime) {
        this.regTime = regTime;
    }

    public Date getCancelTime() {
        return cancelTime;
    }

    public void setCancelTime(Date cancelTime) {
        this.cancelTime = cancelTime;
    }

    public boolean getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(boolean isDelete) {
        this.isDelete = isDelete;
    }

    public UserInfo getUserInfo() {
        return userInfo;
    }

    public void setUserInfo(UserInfo userInfo) {
        this.userInfo = userInfo;
    }

    public EventInfo getEventInfo() {
        return eventInfo;
    }

    public void setEventInfo(EventInfo eventInfo) {
        this.eventInfo = eventInfo;
    }

    public Collection<Winner> getWinnerCollection() {
        return winnerCollection;
    }

    public void setWinnerCollection(Collection<Winner> winnerCollection) {
        this.winnerCollection = winnerCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (regID != null ? regID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Registration)) {
            return false;
        }
        Registration other = (Registration) object;
        if ((this.regID == null && other.regID != null) || (this.regID != null && !this.regID.equals(other.regID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Registration[regID=" + regID + "]";
    }

}
